<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="blog/index/include_blog::header">
<style>
	#personnalimg {
		box-shadow: 0 0 20px 0px rgba(0,0,0,1)
	}

	#personnalimg:hover {
        transform: rotateY(360deg);
        background:linear-gradient(146deg,rgba(187,152,255,1),rgba(131,104,220,1));
        border-radius:10px;
    }
	.modal-backdrop {
		filter: alpha(opacity=0)!important;
		opacity: 0!important;
	}
</style>
</head>

<body>
<iframe id="bground" class="visible-lg-block" src="" width="100%" height="100%" style="z-index: -1;width: 100%;position:fixed "></iframe>
<nav th:include="blog/index/include_blog::nav"  class="navbar navbar-default navbar-fixed-top"></nav><!-- 上移悬停下移消失navbar-custom -->
<br><br><br><br><br><br>
<div class="container">
	<div class="row clearfix">
		<div class="col-md-3">
			<div>
				<h3 class="text-center">
					<span>
						<img class="img-circle xzyz" id="personnalimg" th:src="(${#strings.isEmpty(user.avatar)}) ? @{/img/logo/honey-b.png} : @{${user.avatar}}" th:onerror="this.src='img/logo/honey-b.png'" alt="如长时间未加载请刷新试试" height="180" width="180"/>
					</span>
				</h3>
				<h3 class="text-center" style="color: #000">
	                <a th:value="${user.userId}" class="font-bold hand" onclick="openuser(this)" th:text="${user.userName}"></a><input type="hidden" id="userid" th:value="${user.userId}" /><br>
	            </h3>
	            <a class="layui-btn layui-btn-normal" href="/blog" title="返回博客广场">返回</a><a class="layui-btn layui-btn-normal pull-right" id="sign" title="签到">签到<span class="hidden" id="issign" th:text="${userdetail.issign}"></span></a>
			</div>
		</div>
		<div class="col-md-8 column">
			<div class="wrapper wrapper-content animated fadeInRight" style="background-color:rgba(0,0,0,0)">
			    <div class="row">
			        <div class="col-lg-12 col-md-12 col-sm-12" style="background-color:rgba(0,0,0,0)">
			            <div class="ibox" style="background-color:rgba(0,0,0,0)">
			                <div class="ibox-title " style="background-color:rgba(0,0,0,0)">
			                    <div class="bg-danger" style="background-color:rgba(0,0,0,0)">
			                        <br>
				                    <button class="layui-btn layui-btn-primary zcuti" data-toggle="modal" data-target="#myFans">
										我的粉丝：<span th:text="${userdetail.fans}"></span>
									</button>
									<button class="layui-btn layui-btn-primary zcuti" data-toggle="modal" data-target="#myFocus">
										我的关注：<span th:text="${userdetail.focus}"></span>
									</button>
				                    <button class="layui-btn layui-btn-primary zcuti" data-toggle="modal" data-target="#myIntegrate">
										我的积分：<span id="integrate" th:text="${userdetail.integrate}"></span>
									</button>
									<!-- 模态框（Modal） -->
									<div class="modal fade" id="myIntegrate" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<h4 class="modal-title" id="myModalLabel">
														关于积分
													</h4>
												</div>
												<div class="modal-body">
												    <div>
													       <span >积分获取</span>
													       <p>
														       <span>1.新注册用户系统会自动给分配5积分；</span><br>
														       <span>2.每日签到可增加1分；</span>
													       </p>
												    </div>
													<div>
													       <span>积分使用</span>
													       <p>
														       <span>1.本积分可用于发布帖子，每发布一个帖子扣1分；</span><br>
														       <span>2.修改个人信息，每修改成功一次扣1分；</span><br>
													       </p>
													</div>
												</div>
												<div class="modal-footer">
													<button type="button" class="layui-btn layui-btn-danger" 
															data-dismiss="modal">关闭
													</button>
												</div>
											</div>
										</div>
									</div>
				                                
				                    <button class="layui-btn layui-btn-primary zcuti" data-toggle="modal" data-target="#myMoney">
										我的好币：<span th:text="${userdetail.money}"></span>
									</button>
									<!-- 模态框（Modal） -->
									<div class="modal fade" id="myMoney" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
										<div class="modal-dialog">
											<div class="modal-content">
												<div class="modal-header">
													<button type="button" class="close" data-dismiss="modal" 
															aria-hidden="true">×
													</button>
													<h4 class="modal-title" id="myModalLabel">
														关于好币
													</h4>
												</div>
												<div class="modal-body">
													<span>1.好币可以用于兑换积分，一个好币兑换10积分；</span>
												</div>
												<div class="modal-footer">
												    <button type="button" class="layui-btn layui-btn-danger" 
															data-dismiss="modal">关闭
													</button>
												</div>
											</div>
										</div>
									</div>
				                         
				                    <button class="layui-btn layui-btn-primary zcuti" data-toggle="modal" data-target="#myFocus">
										访问量：<span th:text="${userdetail.visits}"></span>
									</button>        
			                    </div>
			                    <br>
			                </div>
			                
			                
			                
			                <div class="gg-nav" style="background-color:#FFF">
		                        <ul class="nav nav-tabs">
		                            <li class="active"><a href="#blog_info" data-toggle="tab">我的博客</a></li>
		                            <li class="pull-right"><a href="#pwd_info" data-toggle="tab">修改密码</a></li>
		                            <li class="pull-right"><a href="#basic_info" data-toggle="tab">基本资料</a></li>
		                        </ul>
		                    </div>
			                <div class="tab-content" style="background-color:rgba(0,0,0,0)">
			                    <!--blog_info-->
			                    <div class="ibox-content tab-pane fade in active" id="blog_info" style="background-color:rgba(0,0,0,0)">
			                        <div class="tabbable" id="tabs-300948">
										<ul class="nav nav-tabs fontsize18 tcuti">
											<li class="active">
												 <a href="#panel1" data-toggle="tab" >我的评论</a>
											</li>
											<li>
												 <a href="#panel2" id="tab1" data-toggle="tab" >我的帖子</a>
											</li>
											<li>
												 <a href="#panel3" id="tab2" data-toggle="tab" >我的收藏</a>
											</li>
											<li>
												 <a href="#panel4" id="tab3" data-toggle="tab" >粉丝关注</a>
											</li>
											<li>
												 <a href="#panel5" id="tab4" data-toggle="tab" >发布帖子</a>
											</li>
										</ul>
										<div class="tab-content">
											<div class="tab-pane active" id="panel1">
												<div class="col-md-12">
													<div id="mainContent" >
													    <div class="row" id="mainContentChild1"></div>
													</div>
													<div class="clearfix" id="nextpage">
														<p id="allcontent1" class="blog-allcontent"><span>我是有底线的ε(┬┬﹏┬┬)3</span></p>
														<a id="morecontent1" style="display: none;" class="btn btn-secondary float-right" href="javascript:void(0)" onclick="nextPage1()"><span class="fontsize25">更多内容<i class="fa fa-arrow-right"></i></span></a>
													</div>
												</div>
											</div>
											<div class="tab-pane" id="panel2">
												<div class="col-md-12">
													<div id="mainContent" >
													    <div class="row" id="mainContentChild2"></div>
													</div>
													<div class="clearfix" id="nextpage">
														<p id="allcontent2" class="blog-allcontent"><span>我是有底线的ε(┬┬﹏┬┬)3</span></p>
														<a id="morecontent2" style="display: none;" class="btn btn-secondary float-right" href="javascript:void(0)" onclick="nextPage2()"><span class="fontsize25">更多内容<i class="fa fa-arrow-right"></i></span></a>
													</div>
												</div>
											</div>
											<div class="tab-pane" id="panel3">
												<div class="col-md-12">
													<div id="mainContent" >
													    <div class="row" id="mainContentChild3"></div>
													</div>
													<div class="clearfix" id="nextpage">
														<p id="allcontent3" class="blog-allcontent"><span>我是有底线的ε(┬┬﹏┬┬)3</span></p>
														<a id="morecontent3" style="display: none;" class="btn btn-secondary float-right" href="javascript:void(0)" onclick="nextPage3()"><span class="fontsize25">更多内容<i class="fa fa-arrow-right"></i></span></a>
													</div>
												</div>
											</div>
											<div class="tab-pane" id="panel4">
												<div class="col-md-12">
													<div id="mainContent" >
													    <div class="row" id="mainContentChild4"></div>
													</div>
													<div class="clearfix" id="nextpage">
														<p id="allcontent4" class="blog-allcontent"><span>我是有底线的ε(┬┬﹏┬┬)3</span></p>
														<a id="morecontent4" style="display: none;" class="btn btn-secondary float-right" href="javascript:void(0)" onclick="nextPage4()"><span class="fontsize25">更多内容<i class="fa fa-arrow-right"></i></span></a>
													</div>
												</div>
											</div>
											<div class="tab-pane" id="panel5">
												<div class="ibox-content">
													<form class="form-horizontal m-t" id="form-blogcontent-add">
														<a class="hand textdanlan" title="发布成功之后在此界面还可修改,每次修改发布成功后都会扣除1个....!" onclick="wxts()">温馨提示?</a><hr>
														<div class="row">
											        		<div class="form-group col-sm-8">    
												                <label class="col-sm-2 control-label">标题：</label>
												                <div class="col-sm-10">
												                    <input id="blog-add-title" name="title" class="form-control" type="text">
												                </div>
												            </div>
												            <div class="form-group col-sm-4">    
												                <label class="col-sm-4 control-label textdanlan hand" title="选择正确的标签有助于提升帖子的曝光率哦...">标签：</label>
												                <div class="col-sm-8">
												                    <select name="tags" class="form-control m-b" th:with="type=${@dict.getType('blog_tags')}">
												                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
												                    </select>
												                </div>
												            </div>
											        	</div>
											        	<div class="row">
											        		<div class="form-group">    
												                <div class="col-sm-12">
												                    <input id="blog-add-content" type="hidden" class="form-control" name="content">
												                    <div class="summernote" id="content"></div>
												                </div>
												            </div>
											        	</div>
											            <div class="row">
												            <div class="form-group col-sm-6">    
												                <label class="col-sm-5 control-label">开启评论：</label>
												                <div class="col-sm-6">
																	<select name="allowComment" class="form-control m-b">
												                        <option value="1">允许评论</option>
												                        <option value="2">禁止评论</option>
												                    </select>
																</div>
												            </div>
												            <div class="form-group col-sm-6">    
												                <label class="col-sm-5 control-label">是否发布：</label>
												                <div class="col-sm-6">
																	<select name="status" class="form-control m-b">
												                        <option value="1">发布</option>
												                        <option value="2">草稿</option>
												                    </select>
																</div>
												            </div>
											            </div>
													</form>
													<div class="text-right form-group">
														<button class="btn btn-primary" onclick="commitblog()">发布帖子</button>
													</div>
												</div>
											</div>
										</div>
									</div>              
			                    </div>
			                    <!--basic info-->
			                    <div class="ibox-content tab-pane fade"  id="basic_info">
			                        <div class="gg-btnGroup" >
			                        	<p class="text-center fontsize35">用户基本信息</p>
			                     		<form class="form-horizontal m" id="myinfo-edit">
				                     		<div class="row" th:object="${user}">
				                     			<input name="userId" th:value="${user.userId}" type="hidden">
									            <div class="form-group">    
									                <label class="col-sm-3 control-label is-required">用户名称：</label>
									                <div class="col-sm-8">
									                    <input name="userName" th:value="${user.userName}" class="form-control" type="text" required>
									                </div>
									            </div>
									            <div class="form-group">    
									                <label class="col-sm-3 control-label is-required">我的邮箱：</label>
									                <div class="col-sm-8">
									                    <input name="email" th:value="${user.email}" class="form-control" type="text" required>
									                </div>
									            </div>
									            <div class="form-group">    
									                <label class="col-sm-3 control-label is-required">电话号码：</label>
									                <div class="col-sm-8">
									                    <input name="phonenumber" th:value="${user.phonenumber}" class="form-control" type="text" required>
									                </div>
									            </div>
									            <div class="form-group">
							                        <label class="col-sm-3 control-label">用户性别：</label>
							                        <div class="col-sm-8">
							                            <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
											                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
											            </select>
							                        </div>
							                    </div>
							                    
							                    <div class="form-group">
							                        <label class="col-xs-2 control-label">备注：</label>
							                        <div class="col-xs-10">
							                            <textarea name="remark" maxlength="500" class="form-control" rows="3">[[${user.remark}]]</textarea>
							                        </div>
							                    </div>
				                     		</div>
								        </form>
								        <div class="gg-btnGroup">
				                            <button type="button" class="layui-btn layui-btn-normal pull-right" onclick="saveinfo()">保存</button>
				                        </div>
			                        </div>
			                    </div>
			                    <!--pwd_info-->
			                    <div class="ibox-content tab-pane fade" id="pwd_info">
			                        <form class="gg-form" role="form" id="modifyPwd">
			                            <a id="logout" class="hidden" href="/logout"></a>
			                            <input type="hidden" name ="userDO.userId" th:value="${user.userId}"/><!-- name必须为userDo.userId,否则接收不到当前用户id此步骤Objects.equals(userVO.getUserDO().getUserId(), userDO.getUserId())为false -->
			                            <div class="gg-formGroup">
			                                <div class="gg-formTitle">
			                                    <em class="gg-star">*</em>
			                                    <span>旧密码:</span>
			                                </div>
			                                <div class="gg-formDetail gg-dashed">
			                                    <input type="password" class="form-control gg-border0" id="pwdOld" name="pwdOld" placeholder="请输入旧密码" />
			                                    <span class="fa fa-eye gg-faeye" title="鼠标移入显示内容"></span>
			                                </div>
			                            </div>
			                            <div class="gg-formGroup">
			                                <div class="gg-formTitle">
			                                    <em class="gg-star">*</em>
			                                    <span>新密码:</span>
			                                </div>
			                                <div class="gg-formDetail gg-dashed">
			                                    <input type="password" class="form-control gg-border0" id="pwdNew" name="pwdNew" placeholder="请输入新密码" />
			                                    <span class="fa fa-eye gg-faeye" title="鼠标移入显示内容"></span>
			                                </div>
			                            </div>
			                            <div class="gg-formGroup">
			                                <div class="gg-formTitle">
			                                    <em class="gg-star">*</em>
			                                    <span>确认密码:</span>
			                                </div>
			                                <div class="gg-formDetail gg-dashed">
			                                    <input type="password" class="form-control gg-border0" id="confirm_password" name="confirm_password" placeholder="请确认密码" />
			                                    <span class="fa fa-eye gg-faeye" title="鼠标移入显示内容"></span>
			                                </div>
			                            </div>
			                        </form>
			                        <div class="gg-btnGroup">
			                            <button type="button" class="layui-btn layui-btn-normal" id="pwd_save">保存</button>
			                        </div>
			                    </div>
			                    <!--htgl_info-->
			                    <div class="ibox-content tab-pane fade" id="htgl_info">
			                                                                       
			                    </div>
			                </div>
			                
			            </div>
			        </div>
			    </div>
			</div>
		</div>
		<div class="col-md-1 column">
		</div>
	</div>
</div>

<div th:include="blog/index/include_blog::footer"></div>
<script type="text/javascript">
		var userId=$("#userId").text();
		var pagenum1 = 1;
		var pagesize1= 6;
		var url1 = '/blog/user/homecomment?pageSize='+ pagesize1 +'&pageNum=';
		var pagenum2 = 1;
		var pagesize2= 6;
		var url2 = '/blog/user/homecontent?pageSize='+ pagesize2 +'&pageNum=';
		var pagenum3 = 1;
		var pagesize3= 6;
		var url3 = '/blog/user/homefavoritecontent?pageSize='+ pagesize3 +'&pageNum=';
		var pagenum4 = 1;
		var pagesize4= 6;
		var url4 = '/blog/user/fans?pageSize='+ pagesize4 +'&pageNum=';
		$(function(){
			if($("#issign").text()==1){
				$("#sign").html("已签");
				$("#sign").attr("class","layui-btn layui-btn-warm pull-right");
				$("#sign").attr("id","alreadysign");
			}
			loadingBlog2(url1,pagenum1,mainContentChild1,allcontent1,morecontent1,1);
			loadingBlog2(url2,pagenum2,mainContentChild2,allcontent2,morecontent2,2);
			loadingBlog2(url3,pagenum3,mainContentChild3,allcontent3,morecontent3,3);
			loadingBlog2(url4,pagenum4,mainContentChild4,allcontent4,morecontent4,4);
			
			$('.summernote').summernote({
                lang: 'zh-CN',
                height: 200,
                callbacks: {
                    onChange: function(contents, $edittable) {
                        $("input[name='" + this.id + "']").val(contents);
                    },
                    onImageUpload: function(files) {
                    	var obj = this;
                    	var data = new FormData();
                    	data.append("file", files[0]);
                    	$.ajax({
                    		type: "post",
                    		url: ctx + "common/upload",
                    		data: data,
                    		cache: false,
                    		contentType: false,
                    		processData: false,
                    		dataType: 'json',
                    		success: function(result) {
                    			if (result.code == web_status.SUCCESS) {
                    				$('#' + obj.id).summernote('insertImage', result.url);
                    			} else {
                    				$.modal.alertError(result.msg);
                    			}
                    		},
                    		error: function(error) {
                    			$.modal.alertWarning("图片上传失败。");
                    		}
                    	});
                    }
                }
            });
		});
		//不知什么情况jquery修改后的id点击时获取的还是原id
		$("#alreadysign").click(function(){
			layer.msg("你已经签过了，请明日再来吧！");
		})
		
		function nextPage1(){
			loadingBlog2(url1,pagenum1,mainContentChild1,allcontent1,morecontent1,1);
		}
		
		function nextPage2(){
			loadingBlog2(url2,pagenum2,mainContentChild2,allcontent2,morecontent2,2);
		}
		
		function nextPage3(){
			loadingBlog2(url3,pagenum3,mainContentChild3,allcontent3,morecontent3,3);
		}
		
		function nextPage4(){
			loadingBlog2(url4,pagenum4,mainContentChild4,allcontent4,morecontent4,4);
		}
		
		//删除评论
		function removecomment(obj){
			layer.confirm('你确认要删除当前评论吗?', {
				  btn: ['确定','取消']
				}, function(){
					$.ajax({
						url: "/blog/close/blogcomment/remove",
						type:"POST",
						data:{'commentId':$(obj).attr("value")},
						success:function(r){
							layer.msg(r.msg);
							$("#mainContentChild1").empty();
							pagenum1=1;
							loadingBlog2(url1,pagenum1,mainContentChild1,allcontent1,morecontent1,1);
						}
					});
					//layer.msg('已删除'+$(obj).attr("value"));
				}, function(){
				  layer.msg("已取消");
				});
		}
		
		//删除评论
		function saveinfo(){
			layer.confirm('你确认保存吗?保存成功后将会扣除一个积分!', {
				  btn: ['确定','取消']
				}, function(){
					$.ajax({
						url: "/blog/user/editPersonal",
						type:"POST",
						data:$('#myinfo-edit').serialize(),
						success:function(r){
							layer.msg(r.msg);
							if(r.code==1){
								var p=parseInt($("#integrate").text());
								$("#integrate").text(p-1);
							}
						}
					});
				}, function(){
				  layer.msg("已取消");
				});
		}
		
		function commitblog() {
			var title = $("#blog-add-title").val();
			var content = $("#blog-add-content").val();
			if(title==""){
				return layer.alert("请填写帖子标题!");
			}
			if(content==""){
				return layer.alert("帖子内容不能为空!");
			}
			if(content.length>10000){
				return layer.alert("帖子内容过长!");
			}
            layer.confirm('你确认提交当前帖子吗?保存成功后将会扣除一个积分!', {
				  btn: ['确定','取消']
				}, function(){
					$.ajax({
						url: "/blog/blogcontent/add",
						type: "POST",
						data: $('#form-blogcontent-add').serialize(),
						success:function(r){
							if(r.code==500){
								return layer.msg(r.msg);
							}
							layer.msg(r.msg);
							var p=parseInt($("#integrate").text());
							$("#integrate").text(p-1);
							$("#mainContentChild2").empty();
							pagenum2=1;
							loadingBlog2(url2,pagenum2,mainContentChild2,allcontent2,morecontent2,2);
							$('#form-blogcontent-add')[0].reset();
							$(".note-editable").empty();
						}
					});
					//layer.msg('已删除'+$(obj).attr("value"));
				}, function(){
				  layer.msg("已取消");
				});
        }
</script>

</body>
</html>
